# Maintainer: Jürgen Pfeifer <juergen@familiepfeifer.de>
# Contributor: Tim S <stahta01@gmail.com>

# Pathnames in this project can get quite long, so at least on Windows
# I recommend to use a short BUILDDIR setting to avoid problems
#

_realname=xmlada
pkgbase=mingw-w64-${_realname}
pkgname=${MINGW_PACKAGE_PREFIX}-${_realname}
pkgver=23.0.0
pkgrel=1
epoch=1
pkgdesc="A full XML suite for Ada (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64')
replaces=("${MINGW_PACKAGE_PREFIX}-${_realname}-gpl")
url="https://github.com/AdaCore/xmlada/"
license=('GPL3')
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc-ada"
             "${MINGW_PACKAGE_PREFIX}-gprbuild-bootstrap-git"
             "${MINGW_PACKAGE_PREFIX}-autotools")
depends=()
source=("xmlada-${pkgver}.tar.gz::https://github.com/AdaCore/xmlada/archive/v${pkgver}.tar.gz")
sha256sums=('66245a68f2e391c8dc8dc50d6d5f109eb3b371e261d095d2002dff3927dd5253')
options=('strip')

build() {

  if [ "${CARCH}" = "x86_64" ]; then
    local _target='x86_64-windows'
  else
    local _target='x86-windows'
  fi

  cd ${srcdir}/xmlada-${pkgver}/
  ./configure \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --prefix=${MINGW_PREFIX} \
    --enable-shared \
    --target=${_target}

  make
}

package() {
  mkdir -p ${pkgdir}${MINGW_PREFIX}/include/xmlada
  mkdir -p ${pkgdir}${MINGW_PREFIX}/lib/xmlada/static
  mkdir -p ${pkgdir}${MINGW_PREFIX}/lib/xmlada/relocatable
  mkdir -p ${pkgdir}${MINGW_PREFIX}/lib/gnat/xmlada

  cd ${srcdir}/xmlada-${pkgver}/
  make -j1 prefix=${pkgdir}${MINGW_PREFIX} INSTALL=cp install

  rm -rf ${pkgdir}${MINGW_PREFIX}/share/examples
  rm -rf ${pkgdir}${MINGW_PREFIX}/share/doc

  # Copy License Files
  mkdir -p ${pkgdir}${MINGW_PREFIX}/share/licenses/$_realname
  cp -pf ${srcdir}/xmlada-${pkgver}/COPYING* \
    ${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}
}
